﻿using System.Web.Mvc;

namespace ExtendedMvc {
	/// <summary>
	/// Used by the view engine to render a strongly typed  view as a Web Forms user control.
	/// </summary>
	/// <typeparam name="TModel">The type of the model.</typeparam>
	public class ModelViewUserControl<TModel> : ViewUserControl<TModel>, IViewDataContainer<TModel> where TModel : class {
		protected string _htmlNamePrefix;

		public ModelViewUserControl() : base() { }

		public ModelViewUserControl(string htmlNamePrefix)
			: this() {
			this._htmlNamePrefix = htmlNamePrefix;
		}

		public string HtmlNamePrefix {
			get { return _htmlNamePrefix; }
			set { _htmlNamePrefix = value; }
		}

		public new ModelViewHelper<TModel> Html { get { return new ModelViewHtmlHelper<TModel>(this, ViewContext); } }

		public new ModelViewHelper<TModel> Ajax { get { return new ModelViewAjaxHelper<TModel>(this, ViewContext); } }
	}

	/// <summary>
	/// Used by the view engine to render a strongly typed  view as a Web Forms user control.
	/// </summary>
	/// <typeparam name="TModel">The type of the model.</typeparam>
	public class ModelViewUserControl : ViewUserControl, IViewDataContainer {
		protected string _htmlNamePrefix;

		public ModelViewUserControl() : base() { }

		public ModelViewUserControl(string htmlNamePrefix)
			: this() {
			this._htmlNamePrefix = htmlNamePrefix;
		}

		public string HtmlNamePrefix {
			get { return _htmlNamePrefix; }
			set { _htmlNamePrefix = value; }
		}

		public new ModelViewHelper Html { get { return new ModelViewHtmlHelper(this, ViewContext); } }

		public new ModelViewHelper Ajax { get { return new ModelViewAjaxHelper(this, ViewContext); } }
	}
}
